{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "668e349f",
   "metadata": {},
   "source": [
    "---\n",
    "* 日期：2022-09-07\\week03（周三）\n",
    "* 课程：python\n",
    "* 记录人：zeng\n",
    "---\n",
    "# 本周学习内容\n",
    "\n",
    ">1. 变量\n",
    ">>1. 变量的定义与声明\n",
    ">>2. 变量名的一般规则\n",
    ">>>1. 变量名只能是字母、数字和下划线的任意组合\n",
    ">>>2. 第一个字符不能是数字\n",
    ">>>3. 中间不能有空格\n",
    ">>>4. 中文可以且能放在第一位\n",
    "\n",
    ">2. 编程的控制流\n",
    ">>1. 条件判断\n",
    ">>2. 循环遍历"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "031dd4f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 变量学习\n",
    "网三_01_ID=\"2200005\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f1126f08",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2200005'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "49f62717",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网三_01_ID\n"
     ]
    }
   ],
   "source": [
    "print(\"网三_01_ID\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "99c908c3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小兰花 小兰花\n",
      "月尊 小兰花\n"
     ]
    }
   ],
   "source": [
    "网三_01_name = \"小兰花\"\n",
    "网三_02_name = 网三_01_name\n",
    "print(网三_01_name,网三_02_name)\n",
    "网三_01_name = \"月尊\"\n",
    "print(网三_01_name,网三_02_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a8d7cc53",
   "metadata": {},
   "source": [
    "# 2.条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86b8e963",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 课本案例 P18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "279e4338",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rest\n"
     ]
    }
   ],
   "source": [
    "# 变量today需要先赋值\n",
    "today = \"Sunday\"\n",
    "condition = \"Heaadache\"\n",
    "\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest\")\n",
    "else:\n",
    "     print(\"Work, work, work\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d134282",
   "metadata": {},
   "outputs": [],
   "source": [
    "#练习题：判断今天是否有python课（time，localtime()），如果有python课，再判断是否在上python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "f248b36a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=7, tm_hour=20, tm_min=11, tm_sec=3, tm_wday=2, tm_yday=250, tm_isdst=0)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "7c81b2b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "20\n",
      "38\n",
      "今天有python\n",
      "python课ing，第三节课了！\n"
     ]
    }
   ],
   "source": [
    "# 创建week_day变量，time_min变量\n",
    "week_day = time.localtime().tm_wday\n",
    "print(week_day)\n",
    "\n",
    "time_hour = time.localtime().tm_hour\n",
    "print(time_hour)\n",
    "\n",
    "time_min = time.localtime().tm_min\n",
    "print(time_min)\n",
    "\n",
    "if week_day == 2:\n",
    "    print(\"今天有python\")\n",
    "    if time_hour == 19:\n",
    "        print(\"python课ing，上课啦！\")\n",
    "    elif time_hour ==18 and time_min > 44:\n",
    "         print(\"python课ing，第一节课下课！\")\n",
    "    elif time_hour == 20 and time_min < 51:\n",
    "         print(\"python课ing，第三节课了！\")\n",
    "    elif time_hour < 18:\n",
    "        print(\"还没开始python课\")\n",
    "    else:\n",
    "        print(\"下课啦！\")\n",
    "else:\n",
    "    print(\"今天没python课，好开心！\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a1be8e5d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help(time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd4f789d",
   "metadata": {},
   "source": [
    "# 循环遍历\n",
    ">1. for循环\n",
    ">2. range()方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "f2ef1ece",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "# 用例2\n",
    "for ch in \"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "fa31455a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# 用例3 默认从0开始（start），5是终点（end） 默认步长是1\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ce090dc",
   "metadata": {},
   "source": [
    "# range()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "b4e6f22b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range 可以创建数组\n",
    "# 用例3 扩展1 起点为1  （可以设置起点）\n",
    "for num in range(1,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "4f7df52d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展2\n",
    "for num in range(1,10,2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6d39dbac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# 用例1\n",
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e2b7bc48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210000001\n",
      "210000004\n",
      "210000007\n",
      "210000010\n",
      "210000013\n",
      "210000016\n",
      "210000019\n",
      "210000022\n",
      "210000025\n",
      "210000028\n",
      "210000031\n",
      "210000034\n",
      "210000037\n",
      "210000040\n",
      "210000043\n",
      "210000046\n",
      "210000049\n"
     ]
    }
   ],
   "source": [
    "# 具体案例\n",
    "for num in range(210000001,210000050,3):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "ff68af42",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "8\n",
      "6\n",
      "4\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展3 起点为1  终点为10 步长step为2\n",
    "for num in range(10,1,-2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "a4fc4582",
   "metadata": {},
   "outputs": [],
   "source": [
    "#黑客帝国"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c078fe4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 课后作业：p35，p43"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
